<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>班级管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function selectClassroom(majorId,iWidth,iHeight)
		{
			// 限定部门查询
			var majorId = document.getElementById(majorId).value;
			var iTop = (window.screen.availHeight - 20 - iHeight) / 2;
		    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
		    var param = 'height=' + iHeight + ', width=' + iWidth + ', top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no';
		    window.open("${ctx}/ems/emsClassroom/select?pageNo=1&pageSize=30&majorId=" + majorId, 'classRoom', param);
		    
		}
		
		function selectTeacher(majorId,iWidth,iHeight)
		{
			// 限定部门查询
			var majorId = document.getElementById(majorId).value;
			var iTop = (window.screen.availHeight - 20 - iHeight) / 2;
		    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
		    var param = 'height=' + iHeight + ', width=' + iWidth + ', top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no';
		    window.open("${ctx}/ems/emsTeacher/select?pageNo=1&pageSize=30&majorId=" + majorId, 'teacher', param);
		    
		}
		
		/* function showMajor(dept)
		{
			var deptId = dept.value;
			
		} */
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ems/emsCourse/">班级列表</a></li>
		<li class="active"><a href="${ctx}/ems/emsCourse/form?id=${emsCourse.id}">班级<shiro:hasPermission name="ems:emsCourse:edit">${not empty emsCourse.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="ems:emsCourse:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="emsCourse" action="${ctx}/ems/emsCourse/save" method="POST" enctype="multipart/form-data" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">班级代码：</label>
			<div class="controls">
				<form:input path="code" htmlEscape="false" maxlength="8" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">班级名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">班级logo：</label>
			<div class="controls">
				<%-- <form:input path="name" htmlEscape="false" maxlength="64" class="input-xlarge required"/> --%>
				<input type="file" name="file" id="logo" class="form-control tbox-width" style="height:40px;" size="1" />
				<!-- <span class="help-inline"><font color="red">*</font> </span> -->
				<c:if test="${not empty emsCourse.logo }">
					<img alt="" src="${emsCourse.logo }" style="width: 50px;height: 50px;">
				</c:if>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属学期：</label>
			<div class="controls">
				<%-- <form:input path="termId" htmlEscape="false" maxlength="64" class="input-xlarge required"/> --%>
				<form:select path="term.id" class="input-medium">
					<%-- <form:option value=""></form:option> --%>
					<c:forEach items="${terms }" var="term" varStatus="stat">
						<form:option value="${term.id }">${term.name }</form:option>
					</c:forEach>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属部门：</label>
			<div class="controls">
				<%-- <form:input path="majorId" htmlEscape="false" maxlength="64" class="input-xlarge required"/> --%>
				<%-- <form:select path="major.dept.id" id="deptId" class="input-medium" onclick="showMajor(this,'major');">
					<c:forEach items="${depts }" var="dept" varStatus="stat">
						<form:option value="${dept.id }">${dept.name }</form:option>
					</c:forEach>
				</form:select> --%>
				
				<select name="major.dept.id" id="dept" class="input-medium" onclick="showMajor(this,'major');">
					<c:forEach items="${depts }" var="dept" varStatus="stat">
						<option ${dept.id eq emsCourse.major.dept.id ? 'selected':''} value="${dept.id }">${dept.name }</option>
					</c:forEach>
				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属专业：</label>
			<div class="controls">
				
				<select name="major.id" id="major" class="input-medium">
					<!-- <option value="">---请选择---</option> -->
					<c:forEach items="${majors }" var="major" varStatus="stat">
						<option ${major.id eq emsCourse.major.id ? 'selected':''} value="${major.id }">${major.name }</option>
					</c:forEach>
				</select>
				
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">学时：</label>
			<div class="controls">
				<form:input path="classHours" htmlEscape="false" maxlength="18" class="input-xlarge required digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">学费：</label>
			<div class="controls">
				<form:input path="fee" htmlEscape="false" class="input-xlarge required number"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">统一折扣：</label>
			<div class="controls">
				<form:input path="discount" htmlEscape="false" value="1" class="input-xlarge  number"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">招生对象：</label>
			<div class="controls">
				<form:input path="face" htmlEscape="false" maxlength="32" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">招生人数：</label>
			<div class="controls">
				<form:input path="num" htmlEscape="false" maxlength="18" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">教室：</label>
			<div class="controls">
				<form:hidden path="classroom.id" id="classRoomId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
				<form:input path="classroom.name" id="classRoomName" htmlEscape="false" maxlength="64" class="input-xlarge "/>
				<input type="button" value="选择教室" onclick="selectClassroom('major',1000,800);"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开课时间：</label>
			<div class="controls">
				<input name="beginTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${emsCourse.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">上课时间：</label>
			<div class="controls">
				<form:input path="classTime" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">任课教师：</label>
			<div class="controls">
				<form:hidden path="teacher.id" id="teacherId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
				<form:input path="teacher.name" id="teacherName" htmlEscape="false" maxlength="64" class="input-xlarge "/>
				<input type="button" value="选择教师" onclick="selectTeacher('major',1000,800);"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">班级类型：</label>
			<div class="controls">
				<form:input path="type" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否启用：</label>
			<div class="controls">
				<%-- <form:input path="status" htmlEscape="false" maxlength="2" class="input-xlarge "/> --%>
				<form:select path="status" class="input-xlarge ">
					<form:option value="1" label="是"/>
					<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ems:emsCourse:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>